package idv.yx.yongproject

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
class MyRecyclerViewAdapter(private val list: List<ItemEntity>) :RecyclerView.Adapter<MyRecyclerViewAdapter.ViewHolder>(){
    inner class ViewHolder(view:View) : RecyclerView.ViewHolder(view) {
        val name: TextView = view.findViewById<TextView>(R.id.tv_item_name)
    }

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_list, parent, false)
        return ViewHolder(view)
    }

    override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        val itemEntity = list[position]
        holder.name.text=itemEntity.name
    }

    override fun getItemCount(): Int {
        return list.size
    }
}